package com.feng.boot.jvm.scheduled;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.stream.IntStream;

/**
 * @author LEE
 */
@Slf4j
@Component
public class JvmScheduled {

    public volatile static ConcurrentMap<String,String> map = new ConcurrentHashMap<>();

//    @Scheduled(fixedRate = 1)
    public void genera(){
        IntStream.range(0,10000).forEach(i -> {
            String s = UUID.randomUUID().toString();
            map.put(s,s);
        });
        log.info("map:", JSON.toJSONString(map));
        System.gc();
    }
    
}
